package com.ideal.gpt.app.local;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.ideal.gpt.GptJobConfig;
import com.ideal.gpt.ability.docqa.caller.DocQaCaller;
import com.lzwork.gpt.utility.caller.GptCallResult;
import com.lzwork.utility.file.FileUtility;
import com.lzwork.utility.file.LineContent;

/**
 * @author LiZheng
 * @date 2023年10月16日 上午10:57:57
 */

public class FastCall
{
	static void chatCall(String input, List<String> history)
	{
		DocQaCaller job = new DocQaCaller(GptJobConfig.url());
		GptCallResult cr = job.callChat(input, "Fas job call", history, null, true);

		if (cr.getException() != null)
			System.out.println(cr.getException());
		else
			System.out.println(cr.getResponse());
	}

	public static void main(String[] args)
	{
		File root = new File("V:/12345/政策比对//");

		String[] docs =
		{
				// "上海市环城绿带管理办法",
				"中华人民共和国食品安全法(2021修正)",
				// "关于加强本市职业病危害项目申报工作的公告"
		};

		for (String doc : docs)
		{
			File folder = FileUtility.getFileSafe(root, doc);
			docCompare(folder);
		}
	}

	static void docCompare(File folder)
	{
		File oldFile = FileUtility.getFileSafe(folder, "old.txt");
		File newFile = FileUtility.getFileSafe(folder, "new.txt");

		List<String> history = new ArrayList<>();

		String oldStr = LineContent.loadString(oldFile);
		String newStr = LineContent.loadString(newFile);

		System.out.println("Old str len: " + oldStr.length());
		System.out.println("New str len: " + newStr.length());

		history.add("这是第一个政策：" + oldStr);
		history.add("这是第二个政策" + newStr);

		String input = "对比一下两段政策的区别。";
		chatCall(input, history);
	}
}
